package com.hbx.residential_service.service.impl;

import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import com.hbx.residential_service.dao.RepairDao;
import com.hbx.residential_service.domain.Repair;
import com.hbx.residential_service.service.RepairService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

@Service
@Transactional
public class RepairServiceImpl implements RepairService{
    @Autowired
    private RepairDao repairDao;

    @Override
    public List<Repair> findAll(int page, int size) {
        PageHelper.startPage(page, size);
        return repairDao.findAll(page,size);
    }

    @Override
    public Repair findDetailById(int rpId) {
        return repairDao.findDetailById(rpId);
    }

    @Override
    public void deleteRepair(int rpId) {
        repairDao.deleteRepair(rpId);
    }

    @Override
    public void UpdateRPById(Repair repair) {
        repairDao.UpdateRPById(repair);
    }

    @Override
    public List<Repair> fsByUsername(String content, int page, int size) {
        PageHelper.startPage(page,size);
        return repairDao.fsByUsername("%"+content+"%",page,size);
    }

    @Override
    public List<Repair> findByUnHandle(int page, int size) {
        PageHelper.startPage(page,size);
        return repairDao.findByUnHandle(page,size);
    }
}
